package com.example.demo.Controller;

import com.example.demo.Mapper.userMapper;
import com.example.demo.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/Test1")
public class userController {
    @Autowired
    userMapper userMapper;
    @GetMapping("/findAll")
//    用于将方法的返回值存储到缓存中。
//    @Cacheable(value = "myStudent")
    public List<User> findAll(){
        List<User> all = userMapper.findAll();
        return all;
    }

    @PostMapping("/Insert")
    public void Insert(@RequestBody User user){
        userMapper.Insert(user);
    }

    @GetMapping("/delete")
    public void Delete(int id){
        userMapper.delete(id);
    }
}
